package com.xauto.pioneer.appuser.adapter;

import android.app.Activity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.xauto.pioneer.appuser.R;
import com.xauto.pioneer.appuser.model.MonthlyRentRuleInfo;

/**停车包月费用列表适配器
 * Created by Administrator on 2018/7/18.
 */

public class ParkingRentRulesAdapter extends AbsAdapter<MonthlyRentRuleInfo> {
    /**
     * 带参方法
     *
     * @param context
     * @param layout
     */
    public ParkingRentRulesAdapter(Activity context, int layout) {
        super(context, layout);
    }
    @Override
    public ViewHolder<MonthlyRentRuleInfo> getHolder() {
        return new TemplateViewHolder();
    }


    private class TemplateViewHolder implements ViewHolder<MonthlyRentRuleInfo> {

        private TextView tv_rentrule_time;
        private TextView tv_rentrule_price;
        private ImageView img_rentrule;

        @Override
        public void initViews(View v, int position) {
            tv_rentrule_time = (TextView) v.findViewById(R.id.tv_rentrule_time);
            tv_rentrule_price = (TextView) v.findViewById(R.id.tv_rentrule_price);
            img_rentrule = (ImageView) v.findViewById(R.id.img_rentrule);
        }

        @Override
        public void updateData(MonthlyRentRuleInfo rentRuleInfo, int position) {
            tv_rentrule_time.setText(rentRuleInfo.rule_name+"("+rentRuleInfo.start_time+"--"+rentRuleInfo.end_time+")");
            tv_rentrule_price.setText("单价￥"+rentRuleInfo.price);

            if(rentRuleInfo.rule_name.equals("夜间")){
                img_rentrule.setImageResource(R.mipmap.ic_monthlypay_night);
            }else if(rentRuleInfo.rule_name.equals("日间")){
                img_rentrule.setImageResource(R.mipmap.ic_monthlypay_day);
            }else if(rentRuleInfo.rule_name.equals("全天")){
                img_rentrule.setImageResource(R.mipmap.ic_monthlypay_allday);
            }
        }

        @Override
        public void doOthers(MonthlyRentRuleInfo orderInfo, int position) {

        }
    }
}
